Skip to content

test: standardize unit tests across all services (31 tests)#54

Open
sliedig wants to merge 6 commits intodevelopfrom
cross-runtime-test-consolidation
Open

test: standardize unit tests across all services (31 tests)#54
sliedig wants to merge 6 commits intodevelopfrom
cross-runtime-test-consolidation

Conversation

@sliedig
Copy link
Copy Markdown
Contributor

@sliedig sliedig commented Mar 23, 2026

Issue number: N/A

Summary

Changes

Standardize unit tests across all 4 Java modules to achieve exact parity with the Python, .NET, and TypeScript runtimes (31 identical test cases across 7 Lambda functions).

  • Migrate from JUnit 4 to JUnit 5 (Jupiter) with mockito-junit-jupiter across all test modules
  • Add jacoco-maven-plugin with 80% line coverage minimum to all 4 pom.xml files (with exclusions for schema/DAO/model classes)
  • Create shared TestHelpers.java classes with Lambda context factories, SQS/EventBridge/DynamoDB Stream event builders, and JSON fixture loading
  • Create new test files: PropertiesApprovalSyncFunctionTests.java, WaitForContractApprovalFunctionTests.java, RequestApprovalFunctionTests.java, PublicationEvaluationEventHandlerTests.java, PropertySearchFunctionTests.java
  • Remove 4 extra edge-case tests from ContractEventHandler (null event, empty event, missing HttpMethod, empty body) to align test cases across runtimes

User experience

Workshop participants running mvn test will see the same 31 test cases as in the other 3 runtimes, with 80% coverage enforced via JaCoCo at build time. All tests use JUnit 5 annotations and Mockito mocks.

Checklist

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

sliedig added 5 commits March 16, 2026 09:50
- Update Contract model to use String type for contractCreated and contractLastModifiedOn fields
- Remove Long::valueOf conversions in ResponseParser when parsing timestamp values from DynamoDB
- Align timestamp handling with string-based storage in DynamoDB AttributeValue
- Simplifies type conversion and maintains consistency with data source format
…lerFunction and add metrics

- Rename class from ContractEventHandler to ContractEventHandlerFunction for consistency
- Update all constructor references to use new class name
- Update logger initialization to reference new class name
- Add metrics tracking for ContractCreated and ContractUpdated events
- Reorganize imports to follow alphabetical ordering
- Change timestamp fields from Long (epoch millis) to String (ISO-8601 format)
- Update DynamoDB attribute builders to use string type for timestamp fields
- Clean up whitespace inconsistencies throughout the file
…entHandlerFunction

- Update handler field type from ContractEventHandler to ContractEventHandlerFunction
- Update handler instantiation in setUp() to use ContractEventHandlerFunction constructor
- Align test class with recent refactoring that renamed ContractEventHandler to ContractEventHandlerFunction
- Import Powertools metrics classes (Metrics, MetricsFactory, MetricUnit)
- Add validation for evaluation results (APPROVED/DECLINED) in PublicationEvaluationEventHandler
- Track PropertiesApproved metric when property status is updated
- Add SERVICE_NAMESPACE environment variable to RequestApprovalFunction
- Expand RequestApproval event payload with status, listprice, images, description, and currency fields
- Add corresponding getters and setters for new RequestApproval properties
- Use SERVICE_NAMESPACE for EventBridge event source instead of hardcoded "Unicorn.Web"
- Track ApprovalsRequested metric when events are sent to EventBridge
- Improve code formatting and consistency
Migrate to JUnit 5, add coverage tooling (JaCoCo, 80% minimum),
create test helpers and event fixtures, extend test cases for all
7 Lambda functions, and remove extra tests to ensure parity with
Python, .NET, and TypeScript runtimes.
@sliedig sliedig requested a review from a team as a code owner March 23, 2026 09:09
@github-actions
Copy link
Copy Markdown

No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure.

@github-actions
Copy link
Copy Markdown

No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template here: https://github.com/aws-samples/aws-serverless-developer-experience-workshop-java/blob/develop/.github/PULL_REQUEST_TEMPLATE.md#acknowledgment

@github-actions github-actions bot added do-not-merge PRs that are blocked for varying reasons need-license-agreement-acknowledge PRs that are missing acknowledgement section need-issue PR is missing a related issue for tracking change labels Mar 23, 2026
@sliedig sliedig changed the base branch from main to develop March 24, 2026 04:40
Add raw payload JSON fixtures and loadEvent/createSqsEvent helpers.
Refactor tests to load payloads from files instead of inline strings.
Remove 10 stale event files no longer used by tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge PRs that are blocked for varying reasons need-issue PR is missing a related issue for tracking change need-license-agreement-acknowledge PRs that are missing acknowledgement section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant